/*
 * JVM_Method.c
 *
 *  Created on: 14.05.2011
 *      Author: Dominik Ollesz & Roman Richter
 */

#include "JVM_Method.h"

/**
 * Status: working
 */
JVM_Exception_Handler_t* JVM_Method_getExceptionHandlerByIndex(JVM_Method_t *myMethod, uint16_t index) {
	return (myMethod->exception_handler != 0) ?
		(JVM_Exception_Handler_t*) &(*(myMethod->exception_handler+index)) : 0;
}

/**
 * Status: working
 */
JVM_Exception_Handler_t* JVM_Method_getExceptionHandlerByOffset(JVM_Method_t *myMethod, uint16_t index, uint16_t offset) {
	return (myMethod->exception_handler != 0) ?
		(JVM_Exception_Handler_t*) &(*(myMethod->exception_handler+offset+index)) : 0;
}

/**
 * Status: working
 */
short JVM_Method_getExceptionByIndex(JVM_Method_t *myMethod, uint16_t index) {
	return (JVM_Method_throwsException(myMethod)) ?
		myMethod->exceptions->exceptions[index] : -1;
}

/**
 * Status: working
 */
short JVM_Method_getExceptionByOffset(JVM_Method_t *myMethod, uint16_t index, uint16_t offset) {
	return (JVM_Method_throwsException(myMethod)) ?
		myMethod->exceptions->exceptions[offset+index] : -1;
}
